#lang racket

(define-struct address-list (name number))

(define (whose-number number an-addr-list)
  (cond
    [(empty? an-addr-list) false]
    [else (cond
            [(= number (address-list-number (first an-addr-list)))
             (address-list-name (first an-addr-list))]
            [else (whose-number number (rest an-addr-list))]
            )
          ]
    )
  )

(define (phone-number name an-addr-list)
  (cond
    [(empty? an-addr-list) false]
    [else (cond
            [(str-cmp? name (address-list-name (first an-addr-list)))
             (address-list-number (first an-addr-list))]
            [else (phone-number name (rest an-addr-list))]
            )
          ]
    )
  )

(define (str-cmp? s1 s2)
    (symbol=? s1 s2)
  )

; Test
(define an-addr-list
  (cons (make-address-list 'andy '12593)
     (cons (make-address-list 'midea '17951)
        (cons (make-address-list 'wendy '10086) empty)))
  )


(whose-number '12593 an-addr-list)
(phone-number 'wendy an-addr-list)
